package org.rguess.patterns.interfaces.composite;

import java.util.ArrayList;
import java.util.Iterator;

@SuppressWarnings({ "rawtypes", "unchecked", "static-access" })
public class Composite extends AComponent {
	static AComponent component;
	private ArrayList children = new ArrayList();

	public Composite(String name) {
		super(name);
	}

	public void Add(AComponent component) {
		this.component = component;
		children.add(component);
	}

	public void Remove(AComponent component) {
		children.remove(component);
	}

	public void Display(int i) {
		Iterator iter = children.iterator();
		AComponent ac = null;
		ac = (AComponent) iter.next();
		while (iter.hasNext() && iter.next().equals(null)) {
			System.out.println(ac.name);
		}
	}
}